package cn.yi.springboot.druid;

import cn.yi.springboot.druid.page.PageAction;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @author: yiz
 * @date: 2018/8/1 16:33
 **/
public class BaseCurdService<T> {
    public PageInfo<T> findbyPage(Page pageRequest, PageAction action) {
        PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize(), pageRequest.getOrderBy());
        //执行DB操作，PageHelper自动对分页进行查询
        List<?> list =  action.execute();
        PageInfo<T> pageInfo = new PageInfo(list);
        return pageInfo;
    }
}
